from PyQt5.QtWidgets import *
import sys

class Maindemo(QMainWindow):
    def __init__(self,parent=None):
        super(Maindemo,self).__init__(parent)
        self.setWindowTitle("自定义参数")
        button1=QPushButton('button1')
        button2=QPushButton('button2')

        button1.clicked.connect(lambda :self.onButtonClick(1))
        button2.clicked.connect(lambda :self.onButtonClick(2))

        layout=QHBoxLayout()
        layout.addWidget(button1)
        layout.addWidget(button2)
        main_fr=QWidget()
        main_fr.setLayout(layout)
        self.setCentralWidget(main_fr)
    def onButtonClick(self,n):
        print('button{0}按下了'.format(n))
        QMessageBox.information(self,"信息提示",'button{0}按下了'.format(n))
if __name__ == '__main__':
    app=QApplication(sys.argv)
    form=Maindemo()
    form.show()
    sys.exit(app.exec_())